<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ENGINE_add</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>



<ul id="index">
  <li><a href="#NAME">NAME</a></li>
  <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="#DESCRIPTION">DESCRIPTION</a>
    <ul>
      <li><a href="#Reference-counting-and-handles">Reference counting and handles</a></li>
      <li><a href="#Default-implementations">Default implementations</a></li>
      <li><a href="#Application-requirements">Application requirements</a></li>
      <li><a href="#Advanced-configuration-support">Advanced configuration support</a></li>
    </ul>
  </li>
  <li><a href="#ENVIRONMENT">ENVIRONMENT</a></li>
  <li><a href="#RETURN-VALUES">RETURN VALUES</a></li>
  <li><a href="#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="#HISTORY">HISTORY</a></li>
  <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
</ul>

<h1 id="NAME">NAME</h1>

<p>ENGINE_get_DH, ENGINE_get_DSA, ENGINE_by_id, ENGINE_get_cipher_engine, ENGINE_get_default_DH, ENGINE_get_default_DSA, ENGINE_get_default_RAND, ENGINE_get_default_RSA, ENGINE_get_digest_engine, ENGINE_get_first, ENGINE_get_last, ENGINE_get_next, ENGINE_get_prev, ENGINE_new, ENGINE_get_ciphers, ENGINE_get_ctrl_function, ENGINE_get_digests, ENGINE_get_destroy_function, ENGINE_get_finish_function, ENGINE_get_init_function, ENGINE_get_load_privkey_function, ENGINE_get_load_pubkey_function, ENGINE_load_private_key, ENGINE_load_public_key, ENGINE_get_RAND, ENGINE_get_RSA, ENGINE_get_id, ENGINE_get_name, ENGINE_get_cmd_defns, ENGINE_get_cipher, ENGINE_get_digest, ENGINE_add, ENGINE_cmd_is_executable, ENGINE_ctrl, ENGINE_ctrl_cmd, ENGINE_ctrl_cmd_string, ENGINE_finish, ENGINE_free, ENGINE_get_flags, ENGINE_init, ENGINE_register_DH, ENGINE_register_DSA, ENGINE_register_RAND, ENGINE_register_RSA, ENGINE_register_all_complete, ENGINE_register_ciphers, ENGINE_register_complete, ENGINE_register_digests, ENGINE_remove, ENGINE_set_DH, ENGINE_set_DSA, ENGINE_set_RAND, ENGINE_set_RSA, ENGINE_set_ciphers, ENGINE_set_cmd_defns, ENGINE_set_ctrl_function, ENGINE_set_default, ENGINE_set_default_DH, ENGINE_set_default_DSA, ENGINE_set_default_RAND, ENGINE_set_default_RSA, ENGINE_set_default_ciphers, ENGINE_set_default_digests, ENGINE_set_default_string, ENGINE_set_destroy_function, ENGINE_set_digests, ENGINE_set_finish_function, ENGINE_set_flags, ENGINE_set_id, ENGINE_set_init_function, ENGINE_set_load_privkey_function, ENGINE_set_load_pubkey_function, ENGINE_set_name, ENGINE_up_ref, ENGINE_get_table_flags, ENGINE_cleanup, ENGINE_load_builtin_engines, ENGINE_register_all_DH, ENGINE_register_all_DSA, ENGINE_register_all_RAND, ENGINE_register_all_RSA, ENGINE_register_all_ciphers, ENGINE_register_all_digests, ENGINE_set_table_flags, ENGINE_unregister_DH, ENGINE_unregister_DSA, ENGINE_unregister_RAND, ENGINE_unregister_RSA, ENGINE_unregister_ciphers, ENGINE_unregister_digests - ENGINE cryptographic module support</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code> <span class="comment">#include &lt;openssl/engine.h&gt;</span>
 
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_first</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_last</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_next</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_prev</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_add</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_remove</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_by_id</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">char</span> <span class="variable">*id</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_init</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_finish</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 
 <span class="variable">void</span> <span class="variable">ENGINE_load_builtin_engines</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_default_RSA</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_default_DSA</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_default_DH</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_default_RAND</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_cipher_engine</span><span class="operator">(</span><span class="keyword">int</span> <span class="variable">nid</span><span class="operator">);</span>
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_get_digest_engine</span><span class="operator">(</span><span class="keyword">int</span> <span class="variable">nid</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_RSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_DSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_DH</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_RAND</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_ciphers</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_digests</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default_string</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*list</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_set_default</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">unsigned</span> <span class="keyword">int</span> <span class="variable">flags</span><span class="operator">);</span>
 
 <span class="variable">unsigned</span> <span class="keyword">int</span> <span class="variable">ENGINE_get_table_flags</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_set_table_flags</span><span class="operator">(</span><span class="variable">unsigned</span> <span class="keyword">int</span> <span class="variable">flags</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_register_RSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_RSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_RSA</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_DSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_DSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_DSA</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_DH</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_DH</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_DH</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_RAND</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_RAND</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_RAND</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_ciphers</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_ciphers</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_ciphers</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_digests</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_unregister_digests</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">void</span> <span class="variable">ENGINE_register_all_digests</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_complete</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_register_all_complete</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_ctrl</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">cmd</span><span class="operator">,</span> <span class="variable">long</span> <span class="variable">i</span><span class="operator">,</span> <span class="variable">void</span> <span class="variable">*p</span><span class="operator">,</span> <span class="variable">void</span> <span class="operator">(</span><span class="variable">*f</span><span class="operator">)(</span><span class="variable">void</span><span class="operator">));</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_cmd_is_executable</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">cmd</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_ctrl_cmd</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*cmd_name</span><span class="operator">,</span>
                     <span class="variable">long</span> <span class="variable">i</span><span class="operator">,</span> <span class="variable">void</span> <span class="variable">*p</span><span class="operator">,</span> <span class="variable">void</span> <span class="operator">(</span><span class="variable">*f</span><span class="operator">)(</span><span class="variable">void</span><span class="operator">),</span> <span class="keyword">int</span> <span class="variable">cmd_optional</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_ctrl_cmd_string</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*cmd_name</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*arg</span><span class="operator">,</span>
                            <span class="keyword">int</span> <span class="variable">cmd_optional</span><span class="operator">);</span>
 
 <span class="variable">ENGINE</span> <span class="variable">*ENGINE_new</span><span class="operator">(</span><span class="variable">void</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_up_ref</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 
 <span class="keyword">int</span> <span class="variable">ENGINE_set_id</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*id</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_name</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*name</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_RSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">RSA_METHOD</span> <span class="variable">*rsa_meth</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_DSA</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">DSA_METHOD</span> <span class="variable">*dsa_meth</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_DH</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">DH_METHOD</span> <span class="variable">*dh_meth</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_RAND</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">RAND_METHOD</span> <span class="variable">*rand_meth</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_destroy_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">destroy_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_init_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">init_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_finish_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">finish_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_ctrl_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_CTRL_FUNC_PTR</span> <span class="variable">ctrl_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_load_privkey_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_LOAD_KEY_PTR</span> <span class="variable">loadpriv_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_load_pubkey_function</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_LOAD_KEY_PTR</span> <span class="variable">loadpub_f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_ciphers</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_CIPHERS_PTR</span> <span class="variable">f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_digests</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">ENGINE_DIGESTS_PTR</span> <span class="variable">f</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_flags</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">flags</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_set_cmd_defns</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">ENGINE_CMD_DEFN</span> <span class="variable">*defns</span><span class="operator">);</span>
 
 <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*ENGINE_get_id</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*ENGINE_get_name</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">RSA_METHOD</span> <span class="variable">*ENGINE_get_RSA</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">DSA_METHOD</span> <span class="variable">*ENGINE_get_DSA</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">DH_METHOD</span> <span class="variable">*ENGINE_get_DH</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">RAND_METHOD</span> <span class="variable">*ENGINE_get_RAND</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">ENGINE_get_destroy_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">ENGINE_get_init_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_GEN_INT_FUNC_PTR</span> <span class="variable">ENGINE_get_finish_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_CTRL_FUNC_PTR</span> <span class="variable">ENGINE_get_ctrl_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_LOAD_KEY_PTR</span> <span class="variable">ENGINE_get_load_privkey_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_LOAD_KEY_PTR</span> <span class="variable">ENGINE_get_load_pubkey_function</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_CIPHERS_PTR</span> <span class="variable">ENGINE_get_ciphers</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">ENGINE_DIGESTS_PTR</span> <span class="variable">ENGINE_get_digests</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">EVP_CIPHER</span> <span class="variable">*ENGINE_get_cipher</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">nid</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">EVP_MD</span> <span class="variable">*ENGINE_get_digest</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">nid</span><span class="operator">);</span>
 <span class="keyword">int</span> <span class="variable">ENGINE_get_flags</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 <span class="variable">const</span> <span class="variable">ENGINE_CMD_DEFN</span> <span class="variable">*ENGINE_get_cmd_defns</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">);</span>
 
 <span class="variable">EVP_PKEY</span> <span class="variable">*ENGINE_load_private_key</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*key_id</span><span class="operator">,</span>
                                   <span class="variable">UI_METHOD</span> <span class="variable">*ui_method</span><span class="operator">,</span> <span class="variable">void</span> <span class="variable">*callback_data</span><span class="operator">);</span>
 <span class="variable">EVP_PKEY</span> <span class="variable">*ENGINE_load_public_key</span><span class="operator">(</span><span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">,</span> <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*key_id</span><span class="operator">,</span>
                                  <span class="variable">UI_METHOD</span> <span class="variable">*ui_method</span><span class="operator">,</span> <span class="variable">void</span> <span class="variable">*callback_data</span><span class="operator">);</span>
</code></pre>

<p>Deprecated:</p>

<pre><code> #if OPENSSL_API_COMPAT &lt; 0x10100000L
 void ENGINE_cleanup(void)
 #endif</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>These functions create, manipulate, and use cryptographic modules in the form of <b>ENGINE</b> objects. These objects act as containers for implementations of cryptographic algorithms, and support a reference-counted mechanism to allow them to be dynamically loaded in and out of the running application.</p>

<p>The cryptographic functionality that can be provided by an <b>ENGINE</b> implementation includes the following abstractions;</p>

<pre><code> RSA_METHOD - for providing alternative RSA implementations
 DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD,
       - similarly for other OpenSSL APIs
 EVP_CIPHER - potentially multiple cipher algorithms (indexed by &#39;nid&#39;)
 EVP_DIGEST - potentially multiple hash algorithms (indexed by &#39;nid&#39;)
 key-loading - loading public and/or private EVP_PKEY keys</code></pre>

<h2 id="Reference-counting-and-handles">Reference counting and handles</h2>

<p>Due to the modular nature of the ENGINE API, pointers to ENGINEs need to be treated as handles - ie. not only as pointers, but also as references to the underlying ENGINE object. Ie. one should obtain a new reference when making copies of an ENGINE pointer if the copies will be used (and released) independently.</p>

<p>ENGINE objects have two levels of reference-counting to match the way in which the objects are used. At the most basic level, each ENGINE pointer is inherently a <b>structural</b> reference - a structural reference is required to use the pointer value at all, as this kind of reference is a guarantee that the structure can not be deallocated until the reference is released.</p>

<p>However, a structural reference provides no guarantee that the ENGINE is initialised and able to use any of its cryptographic implementations. Indeed it&#39;s quite possible that most ENGINEs will not initialise at all in typical environments, as ENGINEs are typically used to support specialised hardware. To use an ENGINE&#39;s functionality, you need a <b>functional</b> reference. This kind of reference can be considered a specialised form of structural reference, because each functional reference implicitly contains a structural reference as well - however to avoid difficult-to-find programming bugs, it is recommended to treat the two kinds of reference independently. If you have a functional reference to an ENGINE, you have a guarantee that the ENGINE has been initialised and is ready to perform cryptographic operations, and will remain initialised until after you have released your reference.</p>

<p><i>Structural references</i></p>

<p>This basic type of reference is used for instantiating new ENGINEs, iterating across OpenSSL&#39;s internal linked-list of loaded ENGINEs, reading information about an ENGINE, etc. Essentially a structural reference is sufficient if you only need to query or manipulate the data of an ENGINE implementation rather than use its functionality.</p>

<p>The ENGINE_new() function returns a structural reference to a new (empty) ENGINE object. There are other ENGINE API functions that return structural references such as; ENGINE_by_id(), ENGINE_get_first(), ENGINE_get_last(), ENGINE_get_next(), ENGINE_get_prev(). All structural references should be released by a corresponding to call to the ENGINE_free() function - the ENGINE object itself will only actually be cleaned up and deallocated when the last structural reference is released.</p>

<p>It should also be noted that many ENGINE API function calls that accept a structural reference will internally obtain another reference - typically this happens whenever the supplied ENGINE will be needed by OpenSSL after the function has returned. Eg. the function to add a new ENGINE to OpenSSL&#39;s internal list is ENGINE_add() - if this function returns success, then OpenSSL will have stored a new structural reference internally so the caller is still responsible for freeing their own reference with ENGINE_free() when they are finished with it. In a similar way, some functions will automatically release the structural reference passed to it if part of the function&#39;s job is to do so. Eg. the ENGINE_get_next() and ENGINE_get_prev() functions are used for iterating across the internal ENGINE list - they will return a new structural reference to the next (or previous) ENGINE in the list or NULL if at the end (or beginning) of the list, but in either case the structural reference passed to the function is released on behalf of the caller.</p>

<p>To clarify a particular function&#39;s handling of references, one should always consult that function&#39;s documentation &quot;man&quot; page, or failing that the openssl/engine.h header file includes some hints.</p>

<p><i>Functional references</i></p>

<p>As mentioned, functional references exist when the cryptographic functionality of an ENGINE is required to be available. A functional reference can be obtained in one of two ways; from an existing structural reference to the required ENGINE, or by asking OpenSSL for the default operational ENGINE for a given cryptographic purpose.</p>

<p>To obtain a functional reference from an existing structural reference, call the ENGINE_init() function. This returns zero if the ENGINE was not already operational and couldn&#39;t be successfully initialised (eg. lack of system drivers, no special hardware attached, etc), otherwise it will return non-zero to indicate that the ENGINE is now operational and will have allocated a new <b>functional</b> reference to the ENGINE. All functional references are released by calling ENGINE_finish() (which removes the implicit structural reference as well).</p>

<p>The second way to get a functional reference is by asking OpenSSL for a default implementation for a given task, eg. by ENGINE_get_default_RSA(), ENGINE_get_default_cipher_engine(), etc. These are discussed in the next section, though they are not usually required by application programmers as they are used automatically when creating and using the relevant algorithm-specific types in OpenSSL, such as RSA, DSA, EVP_CIPHER_CTX, etc.</p>

<h2 id="Default-implementations">Default implementations</h2>

<p>For each supported abstraction, the ENGINE code maintains an internal table of state to control which implementations are available for a given abstraction and which should be used by default. These implementations are registered in the tables and indexed by an &#39;nid&#39; value, because abstractions like EVP_CIPHER and EVP_DIGEST support many distinct algorithms and modes, and ENGINEs can support arbitrarily many of them. In the case of other abstractions like RSA, DSA, etc, there is only one &quot;algorithm&quot; so all implementations implicitly register using the same &#39;nid&#39; index.</p>

<p>When a default ENGINE is requested for a given abstraction/algorithm/mode, (eg. when calling RSA_new_method(NULL)), a &quot;get_default&quot; call will be made to the ENGINE subsystem to process the corresponding state table and return a functional reference to an initialised ENGINE whose implementation should be used. If no ENGINE should (or can) be used, it will return NULL and the caller will operate with a NULL ENGINE handle - this usually equates to using the conventional software implementation. In the latter case, OpenSSL will from then on behave the way it used to before the ENGINE API existed.</p>

<p>Each state table has a flag to note whether it has processed this &quot;get_default&quot; query since the table was last modified, because to process this question it must iterate across all the registered ENGINEs in the table trying to initialise each of them in turn, in case one of them is operational. If it returns a functional reference to an ENGINE, it will also cache another reference to speed up processing future queries (without needing to iterate across the table). Likewise, it will cache a NULL response if no ENGINE was available so that future queries won&#39;t repeat the same iteration unless the state table changes. This behaviour can also be changed; if the ENGINE_TABLE_FLAG_NOINIT flag is set (using ENGINE_set_table_flags()), no attempted initialisations will take place, instead the only way for the state table to return a non-NULL ENGINE to the &quot;get_default&quot; query will be if one is expressly set in the table. Eg. ENGINE_set_default_RSA() does the same job as ENGINE_register_RSA() except that it also sets the state table&#39;s cached response for the &quot;get_default&quot; query. In the case of abstractions like EVP_CIPHER, where implementations are indexed by &#39;nid&#39;, these flags and cached-responses are distinct for each &#39;nid&#39; value.</p>

<h2 id="Application-requirements">Application requirements</h2>

<p>This section will explain the basic things an application programmer should support to make the most useful elements of the ENGINE functionality available to the user. The first thing to consider is whether the programmer wishes to make alternative ENGINE modules available to the application and user. OpenSSL maintains an internal linked list of &quot;visible&quot; ENGINEs from which it has to operate - at start-up, this list is empty and in fact if an application does not call any ENGINE API calls and it uses static linking against openssl, then the resulting application binary will not contain any alternative ENGINE code at all. So the first consideration is whether any/all available ENGINE implementations should be made visible to OpenSSL - this is controlled by calling the various &quot;load&quot; functions.</p>

<p>The fact that ENGINEs are made visible to OpenSSL (and thus are linked into the program and loaded into memory at run-time) does not mean they are &quot;registered&quot; or called into use by OpenSSL automatically - that behaviour is something for the application to control. Some applications will want to allow the user to specify exactly which ENGINE they want used if any is to be used at all. Others may prefer to load all support and have OpenSSL automatically use at run-time any ENGINE that is able to successfully initialise - ie. to assume that this corresponds to acceleration hardware attached to the machine or some such thing. There are probably numerous other ways in which applications may prefer to handle things, so we will simply illustrate the consequences as they apply to a couple of simple cases and leave developers to consider these and the source code to openssl&#39;s builtin utilities as guides.</p>

<p>If no ENGINE API functions are called within an application, then OpenSSL will not allocate any internal resources. Prior to OpenSSL 1.1.0, however, if any ENGINEs are loaded, even if not registered or used, it was necessary to call ENGINE_cleanup() before the program exits.</p>

<p><i>Using a specific ENGINE implementation</i></p>

<p>Here we&#39;ll assume an application has been configured by its user or admin to want to use the &quot;ACME&quot; ENGINE if it is available in the version of OpenSSL the application was compiled with. If it is available, it should be used by default for all RSA, DSA, and symmetric cipher operations, otherwise OpenSSL should use its builtin software as per usual. The following code illustrates how to approach this;</p>

<pre><code> <span class="variable">ENGINE</span> <span class="variable">*e</span><span class="operator">;</span>
 <span class="variable">const</span> <span class="variable">char</span> <span class="variable">*engine_id</span> <span class="operator">=</span> <span class="string">"ACME"</span><span class="operator">;</span>
 <span class="variable">ENGINE_load_builtin_engines</span><span class="operator">();</span>
 <span class="variable">e</span> <span class="operator">=</span> <span class="variable">ENGINE_by_id</span><span class="operator">(</span><span class="variable">engine_id</span><span class="operator">);</span>
 <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">e</span><span class="operator">)</span>
     <span class="operator">/*</span> <span class="variable">the</span> <span class="variable">engine</span> <span class="variable">isn't</span> <span class="variable">available</span> <span class="operator">*/</span>
     <span class="keyword">return</span><span class="operator">;</span>
 <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">ENGINE_init</span><span class="operator">(</span><span class="variable">e</span><span class="operator">))</span> <span class="operator">{</span>
     <span class="regex">/* the engine couldn't initialise, release 'e' */</span>
     <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
     <span class="keyword">return</span><span class="operator">;</span>
 <span class="operator">}</span>
 <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">ENGINE_set_default_RSA</span><span class="operator">(</span><span class="variable">e</span><span class="operator">))</span>
     <span class="operator">/*</span>
      <span class="operator">*</span> <span class="variable">This</span> <span class="variable">should</span> <span class="variable">only</span> <span class="variable">happen</span> <span class="keyword">when</span> <span class="string">'e'</span> <span class="variable">can't</span> <span class="variable">initialise</span><span class="operator">,</span> <span class="variable">but</span> <span class="variable">the</span> <span class="variable">previous</span>
      <span class="operator">*</span> <span class="variable">statement</span> <span class="variable">suggests</span> <span class="variable">it</span> <span class="variable">did</span><span class="operator">.</span>
      <span class="operator">*</span><span class="regex">/
     abort();
 ENGINE_set_default_DSA(e);
 ENGINE_set_default_ciphers(e);
 /</span><span class="operator">*</span> <span class="variable">Release</span> <span class="variable">the</span> <span class="variable">functional</span> <span class="variable">reference</span> <span class="variable">from</span> <span class="variable">ENGINE_init</span><span class="operator">()</span> <span class="operator">*/</span>
 <span class="variable">ENGINE_finish</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
 <span class="regex">/* Release the structural reference from ENGINE_by_id() */</span>
 <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
</code></pre>

<p><i>Automatically using builtin ENGINE implementations</i></p>

<p>Here we&#39;ll assume we want to load and register all ENGINE implementations bundled with OpenSSL, such that for any cryptographic algorithm required by OpenSSL - if there is an ENGINE that implements it and can be initialised, it should be used. The following code illustrates how this can work;</p>

<pre><code> <span class="regex">/* Load all bundled ENGINEs into memory and make them visible */</span>
 <span class="variable">ENGINE_load_builtin_engines</span><span class="operator">();</span>
 <span class="regex">/* Register all of them for every algorithm they collectively implement */</span>
 <span class="variable">ENGINE_register_all_complete</span><span class="operator">();</span>
</code></pre>

<p>That&#39;s all that&#39;s required. Eg. the next time OpenSSL tries to set up an RSA key, any bundled ENGINEs that implement RSA_METHOD will be passed to ENGINE_init() and if any of those succeed, that ENGINE will be set as the default for RSA use from then on.</p>

<h2 id="Advanced-configuration-support">Advanced configuration support</h2>

<p>There is a mechanism supported by the ENGINE framework that allows each ENGINE implementation to define an arbitrary set of configuration &quot;commands&quot; and expose them to OpenSSL and any applications based on OpenSSL. This mechanism is entirely based on the use of name-value pairs and assumes ASCII input (no unicode or UTF for now!), so it is ideal if applications want to provide a transparent way for users to provide arbitrary configuration &quot;directives&quot; directly to such ENGINEs. It is also possible for the application to dynamically interrogate the loaded ENGINE implementations for the names, descriptions, and input flags of their available &quot;control commands&quot;, providing a more flexible configuration scheme. However, if the user is expected to know which ENGINE device he/she is using (in the case of specialised hardware, this goes without saying) then applications may not need to concern themselves with discovering the supported control commands and simply prefer to pass settings into ENGINEs exactly as they are provided by the user.</p>

<p>Before illustrating how control commands work, it is worth mentioning what they are typically used for. Broadly speaking there are two uses for control commands; the first is to provide the necessary details to the implementation (which may know nothing at all specific to the host system) so that it can be initialised for use. This could include the path to any driver or config files it needs to load, required network addresses, smart-card identifiers, passwords to initialise protected devices, logging information, etc etc. This class of commands typically needs to be passed to an ENGINE <b>before</b> attempting to initialise it, ie. before calling ENGINE_init(). The other class of commands consist of settings or operations that tweak certain behaviour or cause certain operations to take place, and these commands may work either before or after ENGINE_init(), or in some cases both. ENGINE implementations should provide indications of this in the descriptions attached to builtin control commands and/or in external product documentation.</p>

<p><i>Issuing control commands to an ENGINE</i></p>

<p>Let&#39;s illustrate by example; a function for which the caller supplies the name of the ENGINE it wishes to use, a table of string-pairs for use before initialisation, and another table for use after initialisation. Note that the string-pairs used for control commands consist of a command &quot;name&quot; followed by the command &quot;parameter&quot; - the parameter could be NULL in some cases but the name can not. This function should initialise the ENGINE (issuing the &quot;pre&quot; commands beforehand and the &quot;post&quot; commands afterwards) and set it as the default for everything except RAND and then return a boolean success or failure.</p>

<pre><code> <span class="keyword">int</span> <span class="variable">generic_load_engine_fn</span><span class="operator">(</span><span class="variable">const</span> <span class="variable">char</span> <span class="variable">*engine_id</span><span class="operator">,</span>
                            <span class="variable">const</span> <span class="variable">char</span> <span class="operator">**</span><span class="variable">pre_cmds</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">pre_num</span><span class="operator">,</span>
                            <span class="variable">const</span> <span class="variable">char</span> <span class="operator">**</span><span class="variable">post_cmds</span><span class="operator">,</span> <span class="keyword">int</span> <span class="variable">post_num</span><span class="operator">)</span>
 <span class="operator">{</span>
     <span class="variable">ENGINE</span> <span class="variable">*e</span> <span class="operator">=</span> <span class="variable">ENGINE_by_id</span><span class="operator">(</span><span class="variable">engine_id</span><span class="operator">);</span>
     <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">e</span><span class="operator">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="operator">;</span>
     <span class="keyword">while</span> <span class="operator">(</span><span class="variable">pre_num</span><span class="operator">--)</span> <span class="operator">{</span>
         <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">ENGINE_ctrl_cmd_string</span><span class="operator">(</span><span class="variable">e</span><span class="operator">,</span> <span class="variable">pre_cmds</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">,</span> <span class="variable">pre_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span><span class="operator">,</span> <span class="number">0</span><span class="operator">))</span> <span class="operator">{</span>
             <span class="variable">fprintf</span><span class="operator">(</span><span class="variable">stderr</span><span class="operator">,</span> <span class="string">"Failed command (%s - %s:%s)\n"</span><span class="operator">,</span> <span class="variable">engine_id</span><span class="operator">,</span>
                     <span class="variable">pre_cmds</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">,</span> <span class="variable">pre_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span> <span class="operator">?</span> <span class="variable">pre_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span> <span class="operator">:</span> <span class="string">"(NULL)"</span><span class="operator">);</span>
             <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
             <span class="keyword">return</span> <span class="number">0</span><span class="operator">;</span>
         <span class="operator">}</span>
         <span class="variable">pre_cmds</span> <span class="operator">+=</span> <span class="number">2</span><span class="operator">;</span>
     <span class="operator">}</span>
     <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">ENGINE_init</span><span class="operator">(</span><span class="variable">e</span><span class="operator">))</span> <span class="operator">{</span>
         <span class="variable">fprintf</span><span class="operator">(</span><span class="variable">stderr</span><span class="operator">,</span> <span class="string">"Failed initialisation\n"</span><span class="operator">);</span>
         <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
         <span class="keyword">return</span> <span class="number">0</span><span class="operator">;</span>
     <span class="operator">}</span>
     <span class="regex">/*
      * ENGINE_init() returned a functional reference, so free the structural
      * reference from ENGINE_by_id().
      */</span>
     <span class="variable">ENGINE_free</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
     <span class="keyword">while</span> <span class="operator">(</span><span class="variable">post_num</span><span class="operator">--)</span> <span class="operator">{</span>
         <span class="keyword">if</span> <span class="operator">(!</span><span class="variable">ENGINE_ctrl_cmd_string</span><span class="operator">(</span><span class="variable">e</span><span class="operator">,</span> <span class="variable">post_cmds</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">,</span> <span class="variable">post_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span><span class="operator">,</span> <span class="number">0</span><span class="operator">))</span> <span class="operator">{</span>
             <span class="variable">fprintf</span><span class="operator">(</span><span class="variable">stderr</span><span class="operator">,</span> <span class="string">"Failed command (%s - %s:%s)\n"</span><span class="operator">,</span> <span class="variable">engine_id</span><span class="operator">,</span>
                     <span class="variable">post_cmds</span><span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">,</span> <span class="variable">post_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span> <span class="operator">?</span> <span class="variable">post_cmds</span><span class="operator">[</span><span class="number">1</span><span class="operator">]</span> <span class="operator">:</span> <span class="string">"(NULL)"</span><span class="operator">);</span>
             <span class="variable">ENGINE_finish</span><span class="operator">(</span><span class="variable">e</span><span class="operator">);</span>
             <span class="keyword">return</span> <span class="number">0</span><span class="operator">;</span>
         <span class="operator">}</span>
         <span class="variable">post_cmds</span> <span class="operator">+=</span> <span class="number">2</span><span class="operator">;</span>
     <span class="operator">}</span>
     <span class="variable">ENGINE_set_default</span><span class="operator">(</span><span class="variable">e</span><span class="operator">,</span> <span class="variable">ENGINE_METHOD_ALL</span> <span class="operator">&amp;</span> <span class="operator">~</span><span class="variable">ENGINE_METHOD_RAND</span><span class="operator">);</span>
     <span class="regex">/* Success */</span>
     <span class="keyword">return</span> <span class="number">1</span><span class="operator">;</span>
 <span class="operator">}</span>
</code></pre>

<p>Note that ENGINE_ctrl_cmd_string() accepts a boolean argument that can relax the semantics of the function - if set non-zero it will only return failure if the ENGINE supported the given command name but failed while executing it, if the ENGINE doesn&#39;t support the command name it will simply return success without doing anything. In this case we assume the user is only supplying commands specific to the given ENGINE so we set this to FALSE.</p>

<p><i>Discovering supported control commands</i></p>

<p>It is possible to discover at run-time the names, numerical-ids, descriptions and input parameters of the control commands supported by an ENGINE using a structural reference. Note that some control commands are defined by OpenSSL itself and it will intercept and handle these control commands on behalf of the ENGINE, ie. the ENGINE&#39;s ctrl() handler is not used for the control command. openssl/engine.h defines an index, ENGINE_CMD_BASE, that all control commands implemented by ENGINEs should be numbered from. Any command value lower than this symbol is considered a &quot;generic&quot; command is handled directly by the OpenSSL core routines.</p>

<p>It is using these &quot;core&quot; control commands that one can discover the control commands implemented by a given ENGINE, specifically the commands:</p>

<pre><code> ENGINE_HAS_CTRL_FUNCTION
 ENGINE_CTRL_GET_FIRST_CMD_TYPE
 ENGINE_CTRL_GET_NEXT_CMD_TYPE
 ENGINE_CTRL_GET_CMD_FROM_NAME
 ENGINE_CTRL_GET_NAME_LEN_FROM_CMD
 ENGINE_CTRL_GET_NAME_FROM_CMD
 ENGINE_CTRL_GET_DESC_LEN_FROM_CMD
 ENGINE_CTRL_GET_DESC_FROM_CMD
 ENGINE_CTRL_GET_CMD_FLAGS</code></pre>

<p>Whilst these commands are automatically processed by the OpenSSL framework code, they use various properties exposed by each ENGINE to process these queries. An ENGINE has 3 properties it exposes that can affect how this behaves; it can supply a ctrl() handler, it can specify ENGINE_FLAGS_MANUAL_CMD_CTRL in the ENGINE&#39;s flags, and it can expose an array of control command descriptions. If an ENGINE specifies the ENGINE_FLAGS_MANUAL_CMD_CTRL flag, then it will simply pass all these &quot;core&quot; control commands directly to the ENGINE&#39;s ctrl() handler (and thus, it must have supplied one), so it is up to the ENGINE to reply to these &quot;discovery&quot; commands itself. If that flag is not set, then the OpenSSL framework code will work with the following rules:</p>

<pre><code> <span class="keyword">if</span> <span class="keyword">no</span> <span class="variable">ctrl</span><span class="operator">()</span> <span class="variable">handler</span> <span class="variable">supplied</span><span class="operator">;</span>
     <span class="variable">ENGINE_HAS_CTRL_FUNCTION</span> <span class="variable">returns</span> <span class="variable">FALSE</span> <span class="operator">(</span><span class="variable">zero</span><span class="operator">),</span>
     <span class="variable">all</span> <span class="variable">other</span> <span class="variable">commands</span> <span class="variable">fail</span><span class="operator">.</span>
 <span class="keyword">if</span> <span class="variable">a</span> <span class="variable">ctrl</span><span class="operator">()</span> <span class="variable">handler</span> <span class="variable">was</span> <span class="variable">supplied</span> <span class="variable">but</span> <span class="keyword">no</span> <span class="variable">array</span> <span class="variable">of</span> <span class="variable">control</span> <span class="variable">commands</span><span class="operator">;</span>
     <span class="variable">ENGINE_HAS_CTRL_FUNCTION</span> <span class="variable">returns</span> <span class="variable">TRUE</span><span class="operator">,</span>
     <span class="variable">all</span> <span class="variable">other</span> <span class="variable">commands</span> <span class="variable">fail</span><span class="operator">.</span>
 <span class="keyword">if</span> <span class="variable">a</span> <span class="variable">ctrl</span><span class="operator">()</span> <span class="variable">handler</span> <span class="keyword">and</span> <span class="variable">array</span> <span class="variable">of</span> <span class="variable">control</span> <span class="variable">commands</span> <span class="variable">was</span> <span class="variable">supplied</span><span class="operator">;</span>
     <span class="variable">ENGINE_HAS_CTRL_FUNCTION</span> <span class="variable">returns</span> <span class="variable">TRUE</span><span class="operator">,</span>
     <span class="variable">all</span> <span class="variable">other</span> <span class="variable">commands</span> <span class="variable">proceed</span> <span class="variable">processing</span> <span class="operator">...</span>
</code></pre>

<p>If the ENGINE&#39;s array of control commands is empty then all other commands will fail, otherwise; ENGINE_CTRL_GET_FIRST_CMD_TYPE returns the identifier of the first command supported by the ENGINE, ENGINE_GET_NEXT_CMD_TYPE takes the identifier of a command supported by the ENGINE and returns the next command identifier or fails if there are no more, ENGINE_CMD_FROM_NAME takes a string name for a command and returns the corresponding identifier or fails if no such command name exists, and the remaining commands take a command identifier and return properties of the corresponding commands. All except ENGINE_CTRL_GET_FLAGS return the string length of a command name or description, or populate a supplied character buffer with a copy of the command name or description. ENGINE_CTRL_GET_FLAGS returns a bitwise-OR&#39;d mask of the following possible values:</p>

<pre><code> ENGINE_CMD_FLAG_NUMERIC
 ENGINE_CMD_FLAG_STRING
 ENGINE_CMD_FLAG_NO_INPUT
 ENGINE_CMD_FLAG_INTERNAL</code></pre>

<p>If the ENGINE_CMD_FLAG_INTERNAL flag is set, then any other flags are purely informational to the caller - this flag will prevent the command being usable for any higher-level ENGINE functions such as ENGINE_ctrl_cmd_string(). &quot;INTERNAL&quot; commands are not intended to be exposed to text-based configuration by applications, administrations, users, etc. These can support arbitrary operations via ENGINE_ctrl(), including passing to and/or from the control commands data of any arbitrary type. These commands are supported in the discovery mechanisms simply to allow applications to determine if an ENGINE supports certain specific commands it might want to use (eg. application &quot;foo&quot; might query various ENGINEs to see if they implement &quot;FOO_GET_VENDOR_LOGO_GIF&quot; - and ENGINE could therefore decide whether or not to support this &quot;foo&quot;-specific extension).</p>

<h1 id="ENVIRONMENT">ENVIRONMENT</h1>

<dl>

<dt id="OPENSSL_ENGINES"><b>OPENSSL_ENGINES</b></dt>
<dd>

<p>The path to the engines directory. Ignored in set-user-ID and set-group-ID programs.</p>

</dd>
</dl>

<h1 id="RETURN-VALUES">RETURN VALUES</h1>

<p>ENGINE_get_first(), ENGINE_get_last(), ENGINE_get_next() and ENGINE_get_prev() return a valid <b>ENGINE</b> structure or NULL if an error occurred.</p>

<p>ENGINE_add() and ENGINE_remove() return 1 on success or 0 on error.</p>

<p>ENGINE_by_id() returns a valid <b>ENGINE</b> structure or NULL if an error occurred.</p>

<p>ENGINE_init() and ENGINE_finish() return 1 on success or 0 on error.</p>

<p>All ENGINE_get_default_TYPE() functions, ENGINE_get_cipher_engine() and ENGINE_get_digest_engine() return a valid <b>ENGINE</b> structure on success or NULL if an error occurred.</p>

<p>All ENGINE_set_default_TYPE() functions return 1 on success or 0 on error.</p>

<p>ENGINE_set_default() returns 1 on success or 0 on error.</p>

<p>ENGINE_get_table_flags() returns an unsigned integer value representing the global table flags which are used to control the registration behaviour of <b>ENGINE</b> implementations.</p>

<p>All ENGINE_register_TYPE() functions return 1 on success or 0 on error.</p>

<p>ENGINE_register_complete() and ENGINE_register_all_complete() return 1 on success or 0 on error.</p>

<p>ENGINE_ctrl() returns a positive value on success or others on error.</p>

<p>ENGINE_cmd_is_executable() returns 1 if <b>cmd</b> is executable or 0 otherwise.</p>

<p>ENGINE_ctrl_cmd() and ENGINE_ctrl_cmd_string() return 1 on success or 0 on error.</p>

<p>ENGINE_new() returns a valid <b>ENGINE</b> structure on success or NULL if an error occurred.</p>

<p>ENGINE_free() returns 1 on success or 0 on error.</p>

<p>ENGINE_up_ref() returns 1 on success or 0 on error.</p>

<p>ENGINE_set_id() and ENGINE_set_name() return 1 on success or 0 on error.</p>

<p>All other <b>ENGINE_set_*</b> functions return 1 on success or 0 on error.</p>

<p>ENGINE_get_id() and ENGINE_get_name() return a string representing the identifier and the name of the ENGINE <b>e</b> respectively.</p>

<p>ENGINE_get_RSA(), ENGINE_get_DSA(), ENGINE_get_DH() and ENGINE_get_RAND() return corresponding method structures for each algorithms.</p>

<p>ENGINE_get_destroy_function(), ENGINE_get_init_function(), ENGINE_get_finish_function(), ENGINE_get_ctrl_function(), ENGINE_get_load_privkey_function(), ENGINE_get_load_pubkey_function(), ENGINE_get_ciphers() and ENGINE_get_digests() return corresponding function pointers of the callbacks.</p>

<p>ENGINE_get_cipher() returns a valid <b>EVP_CIPHER</b> structure on success or NULL if an error occurred.</p>

<p>ENGINE_get_digest() returns a valid <b>EVP_MD</b> structure on success or NULL if an error occurred.</p>

<p>ENGINE_get_flags() returns an integer representing the ENGINE flags which are used to control various behaviours of an ENGINE.</p>

<p>ENGINE_get_cmd_defns() returns an <b>ENGINE_CMD_DEFN</b> structure or NULL if it&#39;s not set.</p>

<p>ENGINE_load_private_key() and ENGINE_load_public_key() return a valid <b>EVP_PKEY</b> structure on success or NULL if an error occurred.</p>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p><a href="../man3/OPENSSL_init_crypto.html">OPENSSL_init_crypto(3)</a>, <a href="../man3/RSA_new_method.html">RSA_new_method(3)</a>, <a href="../man3/DSA_new.html">DSA_new(3)</a>, <a href="../man3/DH_new.html">DH_new(3)</a>, <a href="../man3/RAND_bytes.html">RAND_bytes(3)</a>, <a href="../man5/config.html">config(5)</a></p>

<h1 id="HISTORY">HISTORY</h1>

<p>ENGINE_cleanup() was deprecated in OpenSSL 1.1.0 by the automatic cleanup done by OPENSSL_cleanup() and should not be used.</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.</p>

<p>Licensed under the OpenSSL license (the &quot;License&quot;). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>


</body>

</html>


